package es.cazadoresmadridejos.model;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;

@Entity(name="Budget")
@Table(name="presupuesto")
public class Budget extends BaseEntity{

	
	private Reason reason;
	private String image;
	private List<BudgetLine> lines = new ArrayList<BudgetLine>();
	
	@ManyToOne(optional=false)
	@JoinColumn(name="temporada")	
	public Reason getReason() {
		return reason;
	}
	public void setReason(Reason reason) {
		this.reason = reason;
	}
	@Column(name="imagen")
	public String getImage() {
		return image;
	}
	public void setImage(String image) {
		this.image = image;
	}
	@OrderBy(value="amount desc")
	@OneToMany(mappedBy="budget",fetch=FetchType.EAGER,cascade=CascadeType.ALL)
	@Cascade( org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
	public List<BudgetLine> getLines() {
		return lines;
	}
	public void setLines(List<BudgetLine> lines) {
		this.lines = lines;
	}
	
	
}
